<template>
  <a-modal
    :title="`家政${model?'编辑':'新增'}`"
    :width="640"
    :visible="visible"
    :confirmLoading="loading"
    @ok="handleOk"
    @cancel="handleCancel"
  >
    <a-spin :spinning="loading">
      <a-form :form="form" v-bind="formLayout">
        <a-form-item v-show="false" label="主键ID">
          <a-input v-decorator="['id']" disabled />
        </a-form-item>
        <a-form-item label="名称">
          <a-input v-decorator="['name']" placeholder="请填写名称"/>
        </a-form-item>
        <a-form-item label="类型">
          <a-select v-decorator="['house_kinds_id']" placeholder="请选择类型">
            <a-select-option :value="item.id" v-for="item in houseKinds" :key="item.id">{{ item.name }}</a-select-option>
          </a-select>
        </a-form-item>
        <a-form-item label="描述">
          <a-textarea v-decorator="['content']" placeholder="请填写描述"></a-textarea>
        </a-form-item>
      </a-form>
    </a-spin>
  </a-modal>
</template>

<script>
import formModalMixin from '@/mixins/formModalMixin'
import { gethouseKinds, houseAdd, houseEdit } from '@/api/house'
// 表单字段
const fields = [ 'name', 'id', 'house_kinds_id', 'content' ]

export default {
  mixins: [formModalMixin],
  data () {
    this.fields = fields
    return {
      houseKinds: [],
      editAction: houseEdit,
      addAction: houseAdd
    }
  },
  created () {
    gethouseKinds().then(res => {
      this.houseKinds = res.data
    })
  }
}
</script>
